import java.util.Arrays;
import java.util.LinkedList;

public class Test {
    //合并两个有序链表
    public static MySingleList.ListNode mergeTwoLists(MySingleList.ListNode head1,
                                               MySingleList.ListNode head2) {

        MySingleList.ListNode newH=new MySingleList.ListNode(-1);
        MySingleList.ListNode tmpH=newH;
        while (head1!=null&&head2!=null) {
            if (head1.val<head2.val) {
                tmpH.next=head1;
                head1=head1.next;
            }else {
                tmpH.next=head2;
                head2=head2.next;
            }
            tmpH=tmpH.next;
        }
        if (head1!=null) {
            tmpH.next=head1;
        }
        if (head2!=null) {
            tmpH.next=head2;
        }
        return newH.next;
    }
    public static void main(String[] args) {
        MySingleList mySingleList=new MySingleList();
        mySingleList.CreateList();
        mySingleList.display();
        System.out.println();
        mySingleList.reverseList();
        mySingleList.display();
        System.out.println();
        System.out.println(mySingleList.ReciprocelKNode(3).val);
        LinkedList<Integer> linkedList=new LinkedList<>();
        linkedList.addLast(1);
        linkedList.addLast(3);
        linkedList.addLast(2);
    }
}
